package models

import (
	"01/dbconnect"
	"gorm.io/gorm"
)

type Test struct {
	gorm.Model
	Id   int
	List string
	Age  int
}

func (Test) TableName() string {
	return "Test"
}

func (t Test) GetTestAll(id int) (Test, error) {
	var test Test
	err := dbconnect.Db.Where("id=?", id).First(&test).Error
	return test, err
}

func (t Test) Update(id int, data string) (Test, error) {
	//test := Test{data}
	//test =data
	dbconnect.Db.Where("id=?", id).Update("list", data).Error
	//dbconnect.Db.Save(data)
	//return test, err
}

func (t Test) Delete(id int) (Test, error) {
	var test Test
	err := dbconnect.Db.Where("id=?", id).Delete(&test).Error
	return test, err
}
